home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pnl010.zip / MDP3.PAS < prev    next >
Pascal/Delphi Source File  |  1992-03-01  |  2KB  |  56 lines

  1. program mdp3;
  2.  
  3. {Program to accompany article in issue #10 of the Pascal NewsLetter.        }
  4. {Author: Mitch Davis, (3:634/384.6) +61-3-890-2062.                         }
  5.  
  6. {This program is a demonstration on how you can make a scroller.  Use the   }
  7. {+/- keys, and q to quit.  This algorithm is used later.                    }
  8.  
  9. uses crt;
  10.  
  11. const ScreenLen = 24;
  12.       LineCount = 100;
  13.       WinTop:integer = 1; {Note MUST be integer}
  14.  
  15. var loop:byte;
  16.     ch:char;
  17.  
  18.   function Min (a,b:word):word;
  19.  
  20.   {Returns the smaller of the two parameters}
  21.  
  22.   begin
  23.     if a < b then Min := a else Min := b;
  24.   end;
  25.  
  26. begin
  27.   {Draw the initial screen}
  28.   gotoxy (1,1);
  29.   for loop := 1 to min (ScreenLen,LineCount-WinTop+1) do writeln (loop,' ');
  30.   write ('*** Use ''+'' to move forward, ''-'' to move back.  ''q'' to quit.');
  31.   {do the scrolling}
  32.   repeat
  33.     ch := readkey;
  34.     case ch of
  35.       '-':if WinTop > 1 then begin
  36.             dec (WinTop);
  37.             gotoxy (1,ScreenLen); {bottom of the screen}
  38.             DelLine;
  39.             gotoxy (1,1); {top of the screen}
  40.             InsLine;
  41.             write (WinTop); {the new line}
  42.           end;
  43.       '+':if WinTop < LineCount-ScreenLen+1 then begin
  44.             inc (WinTop);
  45.             gotoxy (1,1); {top of the screen}
  46.             DelLine;
  47.             gotoxy (1,ScreenLen); {bottom of the screen}
  48.             InsLine;
  49.             write (WinTop+ScreenLen-1); {the new line}
  50.           end;
  51.       'q':; {ensure that it doesn't beep if q is pressed.}
  52.       else write (#7); {beep}
  53.     end;
  54.   until ch = 'q';
  55. end.
  56.